package com.ysstech.finance.controller;

import com.ysstech.common.annotation.YssLog;
import com.ysstech.common.controller.BaseController;
import com.ysstech.common.entity.TreeNode;
import com.ysstech.common.util.resultutil.RestResult;
import com.ysstech.common.util.resultutil.ResultGenerator;
import com.ysstech.finance.entity.Account;
import com.ysstech.finance.service.FinAccountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;


@Controller
@Slf4j
@Api(tags = "基金管理api")
@RequestMapping("/financeAccount")
public class FinAccountController extends BaseController {

    @Autowired
    private FinAccountService finAccountService;

    /**
     * 获取基金树信息
     *
     * @return
     */
    @ApiOperation(value = "获取基金树信息")
    @YssLog(module = "基金管理", remark = "获取基金树信息")
    @PostMapping(value = "/queryAccountTree")
    @ResponseBody
    public RestResult queryAccountTree(Account account) throws Exception {
        return ResultGenerator.getSuccessResult("获取基金树信息成功",
                finAccountService.queryAccountTree(account));
    }


    /**
     * 获取基金树信息
     *
     * @return
     */
    @ApiOperation(value = "获取基金树信息")
    @YssLog(module = "基金管理", remark = "获取基金树信息")
    @PostMapping(value = "/queryAccountTreeByType")
    @ResponseBody
    public List<TreeNode> queryAccountTree(String orgId, Integer fundType, Integer type) throws Exception {
        Account account = new Account();
        account.setOrgId(orgId);
        account.setFundType(fundType);
        account.setType(type);
        return finAccountService.queryAccountTree(account);
    }
}
